Page({
  data: {
    chartDatas: [],

    opts: {
      type: 'radar',
      extra: {
        radar: {
          gridType: "radar",
          gridColor: "#CCCCCC",
          gridCount: 3,
          opacity: 0.2,
          // max: 200,
          labelShow: true,
          border: true
        }
      }
    },
  },
  onReady() {
    // this.getServerData();
  },
  // getServerData() {
  //   //模拟从服务器获取数据时的延时
  //   setTimeout(() => {
  //     //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
  //     let chartData = {
  //       categories: ["2016", "2017", "2018", "2019", "2020", "2021"],
  //       series: [{
  //           name: "目标值",
  //           data: [35, 36, 31, 33, 13, 34]
  //         },
  //         {
  //           name: "完成量",
  //           data: [18, 27, 21, 24, 6, 28]
  //         }
  //       ]
  //     };
  //     this.setData({
  //       chartData
  //     });
  //   }, 500);
  // },
  complete(e) {
    console.log(e);
  },
  tap(e) {
    console.log(e.target.id)
    //  uChartsInstance[e.target.id].touchLegend(e);
  },
  generateShortId() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      const r = Math.random() * 16 | 0;
      const v = c === 'x' ? r : (r & 0x3 | 0x8);
      return v.toString(16);
    });

  },
  add() {
    let item = {
        uuid: this.generateShortId(),
        chartData: {
          categories: ["维度1", "维度2", "维度3", "维度4", "维度5", "维度6"],
          series: [{
              name: "目标值",
              data: [35, 36, 31, 33, 13, 34]
            },
            {
              name: "完成量",
              data: [18, 27, 21, 24, 6, 28]
            }
          ]
        }
      },
      {
        chartDatas
      } = this.data
    chartDatas.push(item)
    this.setData({
      chartDatas
    })
  }
})